package pos.domain;
import java.sql.Connection;
import java.util.Iterator;
import java.util.List;
import pos.data.IExchangeDAO;
import pos.data.JDBCExchangeDAO;


    public class ExchangeManager implements IExchangeManager {
	private IExchangeDAO edao= new JDBCExchangeDAO();
	
	
	public void aceptarIntercambio(String exchangeID){
	         edao.update1(exchangeID);
	}
	public void borrarIntercambio(String exchangeID){
		      edao.delete(exchangeID); 
	}
	
	public List<Exchange> getExchangeReceiveds(String email){
		      return edao.selectReceiveds(email);
	}
	
	/*public List<Exchange> getExchangeSents(String userOID){
	        return edao.selectSents(userOID);
	 }
	
	*/
	 public Exchange getExchangeReceived(String email,String exchangeID) {
		 
	       Exchange result = null;
	       for (Iterator<Exchange> iter = this.getExchangeReceiveds(email).iterator(); iter.hasNext();) {
	            Exchange e = (Exchange) iter.next();
	            if (e.getPropertyReceivedID().compareTo(exchangeID) == 0) {
	                result = e;
	            }
	 }
	        return result;
	    }
    
    public Exchange dameUno(String exchangeID){
    	return edao.select(exchangeID);
    }
    
   
    public void insertExchange(Exchange e){
    	 edao.insert(e);
    }


    public List<Exchange> getExchangeForRating(String email){
    		return edao.selectRecibidosVal(email);
    		
    	}

	
	
	 
	
	
}
